Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates for the API #29

Merged
merged 1 commit into from
Feb 28, 2024
Merged

Updates for the API #29

merged 1 commit into from
Feb 28, 2024

Conversation

nyospe
Copy link
Contributor

@nyospe nyospe commented Feb 27, 2024

This contains the known required API updates.

For hs-builder-core, we can create a struct GlobalStateTxnSubmitter that owns a clone of the Arc<RwLock<GlobalState<NodeType>>>, and implement AcceptsTxnSubmits on that, e.g.

pub struct GlobalStateTxnSubmitter<I: NodeType> {
    pub global_state_handle: Arc<RwLock<GlobalState<I>>>,
}

impl<I: NodeType> AcceptsTxnSubmits<I> for GlobalStateTxnSubmitter<I> {
    async fn submit_txn(&mut self, txn: <I as NodeType>::Transaction) -> Result<(), BuildError> {
        self.global_state_handle.read()?.submit_txn(txn)
    }
}

The GlobalState function for submit_txn will need access to a tx_sender: BroadcastSender<MessageType<Types>>, and can then be

    async fn submit_txn(&self, txn: <Types as BuilderType>::Transaction) -> Result<(), BuildError> {
        let tx_msg = TransactionMessage::<Types> {
            tx: txn,
            tx_type: TransactionSource::HotShot,
        };
        self.tx_sender
            .broadcast(MessageType::TransactionMessage(tx_msg))
            .await
            .map(|a| ())
            .map_err(|e| BuildError::Error {
                message: fmt!("failed to send txn"),
            })
    }

@nyospe nyospe requested review from QuentinI and move47 February 27, 2024 20:01
Copy link
Contributor

@move47 move47 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Changes accommodated in hs-builder-core also!

@nyospe nyospe merged commit f365ad8 into main Feb 28, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants